using System;
using System.Collections.Generic;
using System.Text;

namespace Widgetsphere.Core.DataAccess
{
	[Serializable]
	public partial class PagingObject
	{
		#region Class Members

		private int _pageIndex = 1;
		private int _recordsperPage = 10;
		private string _orderByColumn = "";
		private bool _ascending = true;
		private int _recordCount = 0;

		#endregion

		#region Constructors

		public PagingObject()
		{
		}

		public PagingObject(int pageIndex, int recordsperPage)
			: this(pageIndex, recordsperPage, "", true)
		{
		}

		public PagingObject(int pageIndex, int recordsperPage, string orderByColumn)
			: this(pageIndex, recordsperPage, orderByColumn, true)
		{
		}

		public PagingObject(int pageIndex, int recordsperPage, string orderByColumn, bool ascending)
		{
			if (pageIndex < 1) throw new Exception("The PageIndex must be 1 or greater.");
			if (recordsperPage < 1) throw new Exception("The RecordsPerPage must be 1 or greater.");

			_pageIndex = pageIndex;
			_recordsperPage = recordsperPage;
			_orderByColumn = orderByColumn;
			_ascending = ascending;
		}

		#endregion

		#region Property Implementations

		public int PageIndex
		{
			get { return _pageIndex; }
			set
			{
				if (value < 1) throw new Exception("The PageIndex must be 1 or greater.");
				_pageIndex = value;
			}
		}

		public int RecordsperPage
		{
			get { return _recordsperPage; }
			set
			{
				if (value < 1) throw new Exception("The RecordsperPage must be 1 or greater.");
				_recordsperPage = value;
			}
		}

		public string OrderByColumn
		{
			get { return _orderByColumn; }
			set { _orderByColumn = value; }
		}

		public bool Ascending
		{
			get { return _ascending; }
			set { _ascending = value; }
		}

		public int RecordCount
		{
			get { return _recordCount; }
			set { _recordCount = value; }
		}

		#endregion

	}
}